#!/bin/sh
# fl=$(ls -R |grep ./ |grep -v ./obj |grep -v ./Ld: |grep -v  ./Startup:)
BuildDir="build"
# rm -rf "./${BuildDir}"
ds=`ls -R |grep ./ |grep -v ./obj |grep -v ./Ld: |grep -v  ./Startup:|grep -v $("./${BuildDir}")`
echo "$ds"

# printf '%s' "$a" |awk -F ':' '{print $1}'

# def=`printf '%s' "$a" |awk -F ':' '{print $1}'` 
# def=`echo "$a" |awk -F [.:] '{print NR $2}'` 
# echo "${def}"
def=`echo "${ds}" |awk -F [:] '{print $1}'` 
arr=(${def})
# f=`ls ${arr[@]}`
# echo "${f}"

fls=$(
for dir in ${arr[@]};do
    # `ls "${dir}"` 
    # echo ${dir}
    f=`ls ${dir}`
    # f=$(ls $(dir))
    echo ${f}
done)
csource=$(
for f in $(find -name *.c);do
    cf=$(echo ${f})
    echo "${cf} \\"
done)
# echo "C_SOURCE = \\
# ${csource}"
# echo ${fls}
# echo ${arr[@]}


for dir in ${arr[@]};do
    # `ls "${dir}"` 
    echo ${dir}
    f=`ls ${dir}`
    mkdir -p "./${BuildDir}${dir:1:${#dir}}"
    # echo ${f}
    # f=$(ls $(dir))
    for cf in $(find "${dir}" -name *.c);do
        echo ${cf}
    done
    # echo ${f}
done

dirs=`echo "$def" |awk -F '.' '{print "./bin"$2,$0}'`
# echo "$dirs"
